﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Game.utils;
using java.util;

namespace Game.templates.spawn
{
    public class WalkerRouteTemplate
    {
        public class RouteType
        {
            public static readonly RouteType CYCLE = new RouteType("CYCLE", 0);
            public static readonly RouteType LINEAR = new RouteType("LINEAR",1);
            public static readonly RouteType RANDOM = new RouteType("RANDOM", 2);
            public static readonly RouteType TELEPORT = new RouteType("TELEPORT",3);
            int _id;
            private string _name;
            RouteType(string name,int id)
            {
                _id = id;
                _name = name;
            }
            public IEnumerable<RouteType> Values
            {
                get 
                { 
                    yield return CYCLE;
                    yield return LINEAR;
                    yield return RANDOM;
                    yield return TELEPORT;
                }
            }
        }
        public class Route
        {
            private  int _x, _y, _z, _h;
            private  long _delay;
            private Location _loc;
            private bool _end = false;
            public Route(int x, int y, int z, int h, long delay, bool end)
            {
                _x = x;
                _y = y;
                _z = z;
                _h = h;
                _delay = delay;
                _end = end;
            }
            public Route(int x, int y, int z):this(x, y, z, 0, 0, false)
            {
                //;
            }
            public Route(int x, int y, int z, int h):this(x, y, z, h, 0, false)
            {
                //;
            }
            public Route(int x, int y, int z, long delay):this(x, y, z, 0, delay, false)
            {
                //;
            }
            public Route(int x, int y, int z, long delay, bool end):this(x, y, z, 0, delay, end)
            {
                //;
            }
            public Location getLoc()
            {
                if (_loc == null)
                {
                    _loc = new Location(_x, _y, _z, _h);
                }
                return _loc;
            }
            public int getHeading()
            {
                return _h;
            }
            public long getDelay()
            {
                return _delay;
            }
            public bool getLastPoint()
            {
                return _end;
            }
        }
        private int _npcId;
        private int _walkRange;
        private long _delay;
        private RouteType _type;
        private List _routes = new ArrayList();
        private bool _isRunning = false;
        public WalkerRouteTemplate(int npcId, long delay, RouteType type, bool isRunning, int walkRange)
        {
            _npcId = npcId;
            _delay = delay;
            _type = type;
            _isRunning = isRunning;
            _walkRange = walkRange;
        }
        public void setRoute(int x, int y, int z, int h, long delay, bool end)
        {
            _routes.add(new Route(x, y, z, h, delay, end));
        }
        public void setRoute(int x, int y, int z)
        {
            setRoute(x, y, z, 0, 0, false);
        }
        public void setRoute(Route route)
        {
            setRoute(route);
        }
        public int getNpcId()
        {
            return _npcId;
        }
        public int getWalkRange()
        {
            return _walkRange;
        }
        public long getDelay()
        {
            return _delay;
        }
        public RouteType getRouteType()
        {
            return _type;
        }
        public List getPoints()
        {
            return _routes;
        }
        public int getPointsCount()
        {
            return _routes.size();
        }
        public bool getIsRunning()
        {
            return _isRunning;
        }
    }
}
